<template>
	<view class="page">
		<view class="head">
			<Search @search="search" ref="search" :autoFocus="autoFocus"></Search>
		</view>
		<view class="body">
			<!-- <view class="searchHot">
				
			</view> -->

			
			<view class="information" >
				<!-- <view style="height: 100rpx;" v-if="screenMenuIsShow">
					<view class="information-class" @click="screenMenuIsFixed" :class="screenIsFixed">
						<Screen :screenList="screenList" @change="screenSelectItem"></Screen>
					</view>
				</view> -->
				<view class="infomation-list">
					<InformationItem :infoList="infoList" :isMyPage="false" :isDel="false" :isMenu="true"></InformationItem>
				</view>
			</view>
		</view>
		<view class="bottem">
			<!-- <BackHome v-if="backTopValue"></BackHome> -->
			<BackHome :backTopIsShow="backTopValue"></BackHome>
		</view>
	</view>
</template>

<script>
import Search from "@/components/Search/Search.vue"
import InformationItem from "@/components/InformationItem/InformationItem.vue"
import Screen from "@/components/Screen/Screen.vue"
import BackHome from "@/components/FloatButton/BackHome.vue"
	export default {
		data() {
			return {
				autoFocus:false,
				infoList:[],
				defaultParams:{}, //设置默认的参数对象
				searchKey: '', // 搜索关键字
			}
		},
		async onLoad(option) {  //option为object类型，会序列化上个页面传递的参数
			await this.$onLaunched
			
			this.defaultParams = {cid:getApp().globalData.cityId,openid:getApp().globalData.openid}

		},
		onShow() {
			setTimeout(() => {
				this.autoFocus = true
			},0)
		},

		// onReachBottom(){
		// 	this.currentPage++
		// 	if(this.currentPage <= this.allPage){
		// 		if(this.searchKey){
		// 			let paramsObject = Object.assign(this.defaultParams, {page:this.currentPage, search: this.searchKey})
		// 			this.searchMore(paramsObject)
		// 		} else {
		// 			let paramsObject = Object.assign(this.defaultParams, {page:this.currentPage})
		// 			this.getColumnInfoListMore(paramsObject)
		// 		}
				
		// 	}
		// },
		onPullDownRefresh(){
			this.infoList = [] //让子组件重新加载数据
			if(this.infoClassType == 0){
				this.screenMenuIsShow = false
			}
			this.search(this.searchKey)
		},
		methods: {	
			
			onLoading(time){
				uni.showToast({
				  title: "搜索中...",
				  icon: "loading",
				  duration: time,
				})
			},
			search(key){
				this.searchKey = key
				let paramsObject = Object.assign(this.defaultParams, {search: this.searchKey})
				this.infoList = []
				this.onLoading(100000)
				this.$api.getIndexSearchResult(paramsObject).then(res => {
					console.log(res)
					this.infoList = [...this.infoList, ...res.data]
					this.$forceUpdate()
					uni.hideToast()
				})
			},

		},
		components:{
			Search,
			InformationItem,
			BackHome,
		}
	}
</script>

<style scoped>
@import url("searchResult.css");
</style>
